From 71a311b28e9043c30dd5c817d04ff135042089b4 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 7 Sep 2009 13:51:55 +0100 Subject: [PATCH] vt-d: some small fixes to apic_pin_2_ir_idx 1) apic_pin_2_ir_idx should be int** rahter than unsigned int**, because we use the int -1 to indicate that the related IRTE index is not allocated. 2) shouldn't re-init apic_pin_2_ir_idx when resuming from S3. Signed-off-by: Dexuan Cui --- xen/drivers/passthrough/vtd/intremap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 3f16dc0f15..be5ce34132 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -61,19 +61,23 @@ */ /* apic_pin_2_ir_idx[apicid][pin] = interrupt remapping table index */ -static unsigned int **apic_pin_2_ir_idx; +static int **apic_pin_2_ir_idx; static int init_apic_pin_2_ir_idx(void) { - unsigned int *_apic_pin_2_ir_idx; + int *_apic_pin_2_ir_idx; unsigned int nr_pins, i; + /* Here we shouldn't need to re-init when resuming from S3. */ + if ( apic_pin_2_ir_idx != NULL ) + return 0; + nr_pins = 0; for ( i = 0; i < nr_ioapics; i++ ) nr_pins += nr_ioapic_registers(i); - _apic_pin_2_ir_idx = xmalloc_array(unsigned int, nr_pins); - apic_pin_2_ir_idx = xmalloc_array(unsigned int *, nr_ioapics); + _apic_pin_2_ir_idx = xmalloc_array(int, nr_pins); + apic_pin_2_ir_idx = xmalloc_array(int *, nr_ioapics); if ( (_apic_pin_2_ir_idx == NULL) || (apic_pin_2_ir_idx == NULL) ) { xfree(_apic_pin_2_ir_idx); @@ -512,7 +516,7 @@ static int msi_msg_to_remap_entry( struct iremap_entry *iremap_entry = NULL, *iremap_entries; struct iremap_entry new_ire; struct msi_msg_remap_entry *remap_rte; - unsigned int index; + int index; unsigned long flags; struct ir_ctrl *ir_ctrl = iommu_ir_ctrl(iommu); -- 2.30.2